package com.ruoyi.ade.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * AdeLabResult对象 ade_lab_result
 * 
 * @author wxh
 * @date 2025-06-29
 */
public class AdeLabResult extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** ID */
    private Long id;

    /** Lab ID */
    @Excel(name = "Lab ID")
    private Long labId;

    @Excel(name = "Fold Index")
    private Integer foldIndex;

    /** Match Level */
    @Excel(name = "Match Level")
    private String adeMatchLevel;

    @Excel(name = "Algorithm")
    private String algorithm;

    @Excel(name = "PromptType")
    private String promptType;

    @Excel(name = "LLM")
    private String llm;

    /** Total */
    @Excel(name = "Total")
    private Long total;

    /** True Positive */
    @Excel(name = "True Positive")
    private Long tp;

    /** True Negative */
    @Excel(name = "True Negative")
    private Long tn;

    /** False Positive */
    @Excel(name = "False Positive")
    private Long fp;

    /** False Negative */
    @Excel(name = "False Negative")
    private Long fn;

    /** False Positive Rate */
    @Excel(name = "False Positive Rate")
    private Float fpr;

    /** False Negative Rate */
    @Excel(name = "False Negative Rate")
    private Float fnr;

    /** Precision */
    @Excel(name = "Precision")
    private Float precision;

    /** Recall */
    @Excel(name = "Recall")
    private Float recall;

    /** F1-score */
    @Excel(name = "F1-score")
    private Float f1;

    /** Accuracy */
    @Excel(name = "Accuracy")
    private Float accuracy;

    /** Specificity */
    @Excel(name = "Specificity")
    private Float specificity;

    public AdeLabResult(){}
    public AdeLabResult(Long labId, Integer foldIndex,String algorithm,String promptType,String llm, String adeMatchLevel,int tp, int tn, int fp, int fn) {
        this.labId = labId;
        this.foldIndex = foldIndex;
        this.algorithm = algorithm;
        this.promptType = promptType;
        this.llm = llm;
        this.adeMatchLevel = adeMatchLevel;
        this.tp = new Long(tp);
        this.tn = new Long(tn);
        this.fp = new Long(fp);
        this.fn = new Long(fn);
        this.total = new Long(tp+tn+fp+fn);


        this.precision = (tp+fp)!= 0?tp/(float)(tp+fp):0f;
        this.recall = (tp+fn)!=0?tp/(float)(tp+fn):0f;
        this.specificity = (tn+fp)!=0?tn/(float)(tn+fp):0f;
        this.f1 = (precision+recall)!=0?2*precision*recall/(precision+recall):0f;
        this.fpr = (fp+tn)!=0?fp/(float)(fp+tn):0f;
        this.fnr = (fn+tp)!=0?fn/(float)(fn+tp):0f;
        this.accuracy = (tp+tn)/(float)(tp+tn+fp+fn);
    }

    public String getAlgorithm() {
        return algorithm;
    }

    public void setAlgorithm(String algorithm) {
        this.algorithm = algorithm;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }

    public void setLabId(Long labId) 
    {
        this.labId = labId;
    }

    public Long getLabId() 
    {
        return labId;
    }

    public void setAdeMatchLevel(String adeMatchLevel) 
    {
        this.adeMatchLevel = adeMatchLevel;
    }

    public String getAdeMatchLevel() 
    {
        return adeMatchLevel;
    }

    public void setTotal(Long total) 
    {
        this.total = total;
    }

    public Long getTotal() 
    {
        return total;
    }

    public void setTp(Long tp) 
    {
        this.tp = tp;
    }

    public Long getTp() 
    {
        return tp;
    }

    public void setTn(Long tn) 
    {
        this.tn = tn;
    }

    public Long getTn() 
    {
        return tn;
    }

    public void setFp(Long fp) 
    {
        this.fp = fp;
    }

    public Long getFp() 
    {
        return fp;
    }

    public void setFn(Long fn) 
    {
        this.fn = fn;
    }

    public Long getFn() 
    {
        return fn;
    }

    public Float getFpr() {
        return fpr;
    }

    public void setFpr(Float fpr) {
        this.fpr = fpr;
    }

    public Float getFnr() {
        return fnr;
    }

    public void setFnr(Float fnr) {
        this.fnr = fnr;
    }

    public Float getPrecision() {
        return precision;
    }

    public void setPrecision(Float precision) {
        this.precision = precision;
    }

    public Float getRecall() {
        return recall;
    }

    public void setRecall(Float recall) {
        this.recall = recall;
    }

    public Float getF1() {
        return f1;
    }

    public void setF1(Float f1) {
        this.f1 = f1;
    }

    public Float getAccuracy() {
        return accuracy;
    }

    public void setAccuracy(Float accuracy) {
        this.accuracy = accuracy;
    }

    public Float getSpecificity() {
        return specificity;
    }

    public void setSpecificity(Float specificity) {
        this.specificity = specificity;
    }

    public String getPromptType() {
        return promptType;
    }

    public void setPromptType(String promptType) {
        this.promptType = promptType;
    }

    public String getLlm() {
        return llm;
    }

    public void setLlm(String llm) {
        this.llm = llm;
    }

    public Integer getFoldIndex() {
        return foldIndex;
    }

    public void setFoldIndex(Integer foldIndex) {
        this.foldIndex = foldIndex;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("labId", getLabId())
            .append("adeMatchLevel", getAdeMatchLevel())
            .append("total", getTotal())
            .append("tp", getTp())
            .append("tn", getTn())
            .append("fp", getFp())
            .append("fn", getFn())
            .append("fpr", getFpr())
            .append("fnr", getFnr())
            .append("precision", getPrecision())
            .append("recall", getRecall())
            .append("f1", getF1())
            .append("accuracy", getAccuracy())
            .append("specificity", getSpecificity())
            .append("createTime", getCreateTime())
            .toString();
    }
}
